home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / stra / bluegray.bas < prev    next >
BASIC Source File  |  1995-02-14  |  4KB  |  142 lines

  1. Option Explicit
  2. '----------------------------------------------------------------------
  3. ' global constants, variables and functions used by project.
  4. '----------------------------------------------------------------------
  5.  
  6. Global Const P_WIDTH = 32        ' Width (in pixels) of playing piece.
  7. Global Const BOARD_DIM = 12      ' Number of playing squares on board.
  8.  
  9. ' ScaleMode constants
  10. Global Const TWIPS = 1
  11. Global Const PIXELS = 3
  12.  
  13. ' RGB color constants
  14. Global Const BLUE = &HFF0000
  15. Global Const RED = &HFF&
  16. Global Const BLACK = &H0&
  17. Global Const YELLOW = &HFFFF&
  18. Global Const GREEN = &HFF00&
  19.  
  20. ' Game States
  21. Global Const GAME_OVER = 0
  22. Global Const SELECT_PIECE = 1
  23. Global Const MOVE_PIECE = 2
  24. Global Const DEFENSE_MOVE = 3
  25.  
  26. ' Maximum number of playing pieces per side.
  27. Global Const MAX_PIECES = 15
  28.  
  29. ' Which side?
  30. Global Const NEITHER = -1
  31. Global Const DEFENSE = 0
  32. Global Const OFFENSE = 1
  33.  
  34. ' Game Piece Types
  35. Global Const INFANTRY = 1
  36. Global Const CAVALRY = 2
  37. Global Const ARTILLERY = 3
  38. Global Const SPY = 5
  39. Global Const FLAG = 6
  40.  
  41. ' Strength Constants
  42. Global Const NONE = 0
  43. Global Const LOW = 1
  44. Global Const MODERATE = 2
  45. Global Const HIGH = 3
  46.  
  47. ' Constants for 3D Borders
  48. Global Const BORDER_INSET = 0
  49. Global Const BORDER_RAISED = 1
  50.  
  51. ' Data type that holds the state of a
  52. ' single playing piece.
  53. Type tPiece
  54.     side As Integer
  55.     type As Integer
  56.     strength As Integer
  57.     row As Integer
  58.     col As Integer
  59.     ImageEl As Integer
  60. End Type
  61.  
  62. ' The current mouse location in board rows and columns
  63. Global gMouseRow As Integer
  64. Global gMouseCol As Integer
  65.  
  66. ' Array of offensive pieces
  67. Global gOffense(1 To MAX_PIECES)  As tPiece
  68. Global gLastOffense As Integer
  69.  
  70. ' Array of defensive pieces
  71. Global gDefense(1 To MAX_PIECES)  As tPiece
  72. Global gLastDefense As Integer
  73.  
  74. ' Arrays with descriptions of different game properties
  75. ' stored as strings
  76. Global gPieceName(1 To 6)  As String
  77. Global gStrengthName(0 To 3) As String
  78. Global gSideName(0 To 1)  As String
  79.  
  80. ' The current game state
  81. Global gGameState As Integer
  82.  
  83. ' The currently selected game piece
  84. Global gCurrentPiece As Integer
  85.  
  86. ' Functions and constants used to play sounds.
  87. Declare Function sndPlaySound Lib "MMSystem" (ByVal lpsound As String, ByVal FLAG As Integer) As Integer
  88.  
  89. Global Const SND_SYNC = &H0        ' Return when sound ends (the default)
  90. Global Const SND_ASYNC = &H1       ' Return as soon as sound starts
  91.  
  92. Sub Make3D (AForm As Form, ctl As Control, ByVal BorderStyle As Integer, ByVal BorderWidth As Integer)
  93. '----------------------------------------------------------------------
  94. ' Wrap a 3D effect around a control on a form.
  95. '----------------------------------------------------------------------
  96. ' Color Constants
  97. Const DARK_GRAY = &H808080
  98. Const WHITE = &HFFFFFF
  99. Const BLACK = &H0
  100.  
  101. Dim AdjustX As Integer, AdjustY As Integer
  102. Dim RightSide As Single
  103. Dim BW As Integer
  104. Dim LeftTopColor As Long, RightBottomColor As Long
  105. Dim i As Integer
  106. Dim SaveMode As Integer
  107.  
  108.     If Not ctl.Visible Then Exit Sub
  109.  
  110.     SaveMode = AForm.ScaleMode
  111.     AForm.ScaleMode = TWIPS
  112.  
  113.     AdjustX = Screen.TwipsPerPixelX
  114.     AdjustY = Screen.TwipsPerPixelY
  115.  
  116.     Select Case BorderStyle
  117.     Case 0: ' Inset
  118.         LeftTopColor = DARK_GRAY
  119.         RightBottomColor = WHITE
  120.     Case 1: ' Raised
  121.         LeftTopColor = WHITE
  122.         RightBottomColor = DARK_GRAY
  123.     End Select
  124.  
  125.     ' Set the top shading line.
  126.     For BW = 1 To BorderWidth
  127.     ' Top
  128.     AForm.CurrentX = ctl.Left - (AdjustX * BW)
  129.     AForm.CurrentY = ctl.Top - (AdjustY * BW)
  130.     AForm.Line -(ctl.Left + ctl.Width + (AdjustX * (BW - 1)), ctl.Top - (AdjustY * BW)), LeftTopColor
  131.     ' Right
  132.     AForm.Line -(ctl.Left + ctl.Width + (AdjustX * (BW - 1)), ctl.Top + ctl.Height + (AdjustY * (BW - 1))), RightBottomColor
  133.     ' Bottom
  134.     AForm.Line -(ctl.Left - (AdjustX * BW), ctl.Top + ctl.Height + (AdjustY * (BW - 1))), RightBottomColor
  135.     ' Left
  136.     AForm.Line -(ctl.Left - (AdjustX * BW), ctl.Top - (AdjustY * BW)), LeftTopColor
  137.     Next
  138.  
  139.     AForm.ScaleMode = SaveMode
  140. End Sub
  141.  
  142.